import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

//解决路由重复问题
const originalPush = Router.prototype.push
// 修改 原型对象中的push方法
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}


import Login from '@/views/Login0'
import Register from '@/views/Register'
import Home from '@/views/Home/Home.vue'
import HomeChange from '@/views/Home/HomeChange'
import QuestionnaireDatabase from '@/views/QuestionnaireManagement/QuestionnaireDatabase'
import QuestionnaireReview from '@/views/QuestionnaireManagement/QuestionnaireReview'
import NewQuestionnaire from '@/views/QuestionnaireManagement/NewQuestionnaire'
import PersonalQuestionnaires from '@/views/QuestionnaireManagement/PersonalQuestionnaires'
import QuestionnaireAnalysis from '@/views/DataAnalysis/QuestionnaireAnalysis'
import ResultAnalysis from '@/views/DataAnalysis/ResultAnalysis'
import UserManagement from '@/views/SystemManagement/UserManagement'
import DataDictionary from '@/views/SystemManagement/DataDictionary'
import UserDetail from '@/views/SystemManagement/UserDetail'
import QuestionnaireDetail from '@/views/QuestionnaireManagement/QuestionnaireDetail'
import RoleManagement from '@/views/SystemManagement/RoleManagement'
import PersonalInformation from '@/views/Home/PersonalInformation'

export default new Router({
    routes: [
        {
            path: "/",
            redirect: "/login"
        },
        {
            path: "/login",
            name: 'Login',
            component: Login
        },
        {
            path: "/register",
            name: 'Register',
            component: Register
        },
        {
            path: "/home",
            name: 'Home',
            component: Home,
            meta: { title: '首页' },
        },
        {
            path: "/questionnaireManagement",
            name: 'QuestionnaireManagement',
            component: HomeChange,
            meta: { title: '问卷管理' },
            children: [
                {
                    path: "/questionnaireManagement/questionnaireDatabase",
                    name: "QuestionnaireDatabase",
                    component: QuestionnaireDatabase,
                    meta: {
                        title: '问卷库'
                    }
                },
                {
                    path: "/questionnaireManagement/questionnaireDetail",
                    name: "QuestionnaireDetail",
                    component: QuestionnaireDetail,
                    meta: {
                        title: '问卷详情'
                    }
                },
                {
                    path: "/questionnaireManagement/questionnaireReview",
                    name: "QuestionnaireReview",
                    component: QuestionnaireReview,
                    meta: {
                        title: '问卷审核'
                    }
                },
                {
                    path: "/questionnaireManagement/newQuestionnaire",
                    name: "NewQuestionnaire",
                    component: NewQuestionnaire,
                    meta: {
                        title: '新建问卷'
                    }
                },
                {
                    path: "/questionnaireManagement/editQuestionnaire",
                    name: "EditQuestionnaire",
                    component: NewQuestionnaire,
                    meta: {
                        title: '修改问卷'
                    },
                    hidden: true
                },
                {
                    path: "/questionnaireManagement/personalQuestionnaires",
                    name: "PersonalQuestionnaires",
                    component: PersonalQuestionnaires,
                    meta: {
                        title: '个人问卷'
                    }
                },
            ]
        },
        {
            path: "/dataAnalysis",
            name: 'DataAnalysis',
            component: HomeChange,
            meta: { title: '数据分析' },
            children: [
                {
                    path: "/dataAnalysis/resultAnalysis",
                    name: "ResultAnalysis",
                    component: ResultAnalysis,
                    meta: {
                        title: '结果分析'
                    }
                },
                {
                    path: "/dataAnalysis/questionnaireAnalysis",
                    name: "questionnaireAnalysis",
                    component: QuestionnaireAnalysis,
                    meta: {
                        title: '问卷分析'
                    }
                },
            ]
        },
        {
            path: "/systemManagement",
            name: 'SystemManagement',
            component: HomeChange,
            meta: { title: '系统管理' },
            children: [
                {
                    path: "/systemManagement/userManagement",
                    name: "UserManagement",
                    component: UserManagement,
                    meta: {
                        title: '用户管理'
                    }
                },
                {
                    path: "/systemManagement/userDetail",
                    name: "UserDetail",
                    component: UserDetail,
                    meta: {
                        title: '用户详情'
                    }
                },
                {
                    path: "/systemManagement/dataDictionary",
                    name: "DataDictionary",
                    component: DataDictionary,
                    meta: {
                        title: '数据字典'
                    }
                },
                {
                    path: "/systemManagement/roleManagement",
                    name: "RoleManagement",
                    component: RoleManagement,
                    meta: {
                        title: '角色管理'
                    }
                },
                {
                    path: "/systemManagement/personalInformation",
                    name: "PersonalInformation",
                    component: PersonalInformation,
                    meta: {
                        title: '个人信息'
                    }
                }
            ]
        },
    ]
})